XAPK Installer.apk(点击下载) / m.java


package c.e.a.a.g.b;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Pair;
import com.google.android.gms.analytics.CampaignTrackingReceiver;
import com.google.android.gms.analytics.zza;
import com.google.android.gms.analytics.zzg;
import com.google.android.gms.analytics.zzk;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.wrappers.Wrappers;
import com.google.android.gms.internal.gtm.zzan;
import com.google.android.gms.internal.gtm.zzap;
import com.google.android.gms.internal.gtm.zzar;
import com.google.android.gms.internal.gtm.zzas;
import com.google.android.gms.internal.gtm.zzat;
import com.google.android.gms.internal.gtm.zzbq;
import com.google.android.gms.internal.gtm.zzbv;
import com.google.android.gms.internal.gtm.zzbw;
import com.google.android.gms.internal.gtm.zzby;
import com.google.android.gms.internal.gtm.zzcd;
import com.google.android.gms.internal.gtm.zzcp;
import com.google.android.gms.internal.gtm.zzcq;
import com.google.android.gms.internal.gtm.zzcz;
import com.google.android.gms.internal.gtm.zzda;
import com.google.android.gms.internal.gtm.zzq;
import com.google.android.gms.internal.gtm.zzr;
import com.google.android.gms.internal.gtm.zzu;
import com.google.android.gms.internal.gtm.zzz;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class m extends zzan {
    public boolean f;
    public final k g;
    public final b0 h;
    public final a0 i;
    public final zzat j;
    public long k = Long.MIN_VALUE;
    public final x l;
    public final x m;
    public final h0 n;
    public long o;
    public boolean p;

    public m(zzap zzap, zzar zzar) {
        super(zzap);
        Preconditions.a(zzar);
        this.i = new a0(zzap);
        this.g = new k(zzap);
        this.h = new b0(zzap);
        this.j = new zzat(zzap);
        this.n = new h0(e());
        this.l = new n(this, zzap);
        this.m = new o(this, zzap);
    }

    public final void A() {
        v();
        zzk.d();
        Context a2 = d().a();
        if (!zzcp.a(a2)) {
            d("AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.");
        } else if (!zzcq.a(a2)) {
            e("AnalyticsService is not registered or is disabled. Analytics service at risk of not starting. See http://goo.gl/8Rd3yj for instructions.");
        }
        if (!CampaignTrackingReceiver.a(a2)) {
            d("CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.");
        }
        m().w();
        if (!f("android.permission.ACCESS_NETWORK_STATE")) {
            e("Missing required android.permission.ACCESS_NETWORK_STATE. Google Analytics disabled. See http://goo.gl/8Rd3yj for instructions");
            K();
        }
        if (!f("android.permission.INTERNET")) {
            e("Missing required android.permission.INTERNET. Google Analytics disabled. See http://goo.gl/8Rd3yj for instructions");
            K();
        }
        if (zzcq.a(b())) {
            a("AnalyticsService registered in the app manifest and enabled");
        } else {
            d("AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.");
        }
        if (!this.p && !this.g.z()) {
            D();
        }
        G();
    }

    public final void B() {
        a((zzbw) new q(this));
    }

    public final void C() {
        try {
            this.g.C();
            G();
        } catch (SQLiteException e2) {
            d("Failed to delete stale hits", e2);
        }
        this.m.a(86400000);
    }

    public final void D() {
        if (!this.p && zzbq.c() && !this.j.y()) {
            if (this.n.a(zzby.C.a().longValue())) {
                this.n.b();
                a("Connecting to service");
                if (this.j.w()) {
                    a("Connected to service");
                    this.n.a();
                    w();
                }
            }
        }
    }

    public final boolean E() {
        zzk.d();
        v();
        a("Dispatching a batch of local hits");
        boolean z = !this.j.y();
        boolean z2 = !this.h.w();
        if (!z || !z2) {
            long max = (long) Math.max(zzbq.g(), zzbq.h());
            ArrayList arrayList = new ArrayList();
            long j2 = 0;
            while (true) {
                try {
                    this.g.w();
                    arrayList.clear();
                    try {
                        List<zzcd> b2 = this.g.b(max);
                        if (b2.isEmpty()) {
                            a("Store is empty, nothing to dispatch");
                            I();
                            try {
                                this.g.A();
                                this.g.x();
                                return false;
                            } catch (SQLiteException e2) {
                                e("Failed to commit local dispatch transaction", e2);
                                I();
                                return false;
                            }
                        } else {
                            a("Hits loaded from store. count", Integer.valueOf(b2.size()));
                            for (zzcd zzcd : b2) {
                                if (zzcd.c() == j2) {
                                    d("Database contains successfully uploaded hit", Long.valueOf(j2), Integer.valueOf(b2.size()));
                                    I();
                                    try {
                                        return false;
                                    } catch (SQLiteException e3) {
                                        e("Failed to commit local dispatch transaction", e3);
                                        I();
                                        return false;
                                    }
                                }
                            }
                            if (this.j.y()) {
                                a("Service connected, sending hits to the service");
                                while (!b2.isEmpty()) {
                                    zzcd zzcd2 = b2.get(0);
                                    if (!this.j.a(zzcd2)) {
                                        break;
                                    }
                                    j2 = Math.max(j2, zzcd2.c());
                                    b2.remove(zzcd2);
                                    b("Hit sent do device AnalyticsService for delivery", zzcd2);
                                    try {
                                        this.g.c(zzcd2.c());
                                        arrayList.add(Long.valueOf(zzcd2.c()));
                                    } catch (SQLiteException e4) {
                                        e("Failed to remove hit that was send for delivery", e4);
                                        I();
                                        try {
                                            this.g.A();
                                            this.g.x();
                                            return false;
                                        } catch (SQLiteException e5) {
                                            e("Failed to commit local dispatch transaction", e5);
                                            I();
                                            return false;
                                        }
                                    }
                                }
                            }
                            if (this.h.w()) {
                                List<Long> a2 = this.h.a(b2);
                                for (Long l2 : a2) {
                                    j2 = Math.max(j2, l2.longValue());
                                }
                                try {
                                    this.g.a(a2);
                                    arrayList.addAll(a2);
                                } catch (SQLiteException e6) {
                                    e("Failed to remove successfully uploaded hits", e6);
                                    I();
                                    try {
                                        this.g.A();
                                        this.g.x();
                                        return false;
                                    } catch (SQLiteException e7) {
                                        e("Failed to commit local dispatch transaction", e7);
                                        I();
                                        return false;
                                    }
                                }
                            }
                            if (arrayList.isEmpty()) {
                                try {
                                    this.g.A();
                                    this.g.x();
                                    return false;
                                } catch (SQLiteException e8) {
                                    e("Failed to commit local dispatch transaction", e8);
                                    I();
                                    return false;
                                }
                            } else {
                                try {
                                    this.g.A();
                                    this.g.x();
                                } catch (SQLiteException e9) {
                                    e("Failed to commit local dispatch transaction", e9);
                                    I();
                                    return false;
                                }
                            }
                        }
                    } catch (SQLiteException e10) {
                        d("Failed to read hits from persisted store", e10);
                        I();
                        try {
                            this.g.A();
                            this.g.x();
                            return false;
                        } catch (SQLiteException e11) {
                            e("Failed to commit local dispatch transaction", e11);
                            I();
                            return false;
                        }
                    }
                } finally {
                    try {
                        this.g.A();
                        this.g.x();
                    } catch (SQLiteException e12) {
                        e("Failed to commit local dispatch transaction", e12);
                        I();
                        return false;
                    }
                }
            }
        } else {
            a("No network or service available. Will retry later");
            return false;
        }
    }

    public final void F() {
        zzk.d();
        v();
        b("Sync dispatching local hits");
        long j2 = this.o;
        D();
        try {
            E();
            m().z();
            G();
            if (this.o != j2) {
                this.i.e();
            }
        } catch (Exception e2) {
            e("Sync local dispatch failed", e2);
            G();
        }
    }

    public final void G() {
        long j2;
        zzk.d();
        v();
        boolean z = true;
        if (!(!this.p && J() > 0)) {
            this.i.b();
            I();
        } else if (this.g.z()) {
            this.i.b();
            I();
        } else {
            if (!zzby.z.a().booleanValue()) {
                this.i.c();
                z = this.i.a();
            }
            if (z) {
                H();
                long J = J();
                long y = m().y();
                if (y != 0) {
                    j2 = J - Math.abs(e().a() - y);
                    if (j2 <= 0) {
                        j2 = Math.min(zzbq.e(), J);
                    }
                } else {
                    j2 = Math.min(zzbq.e(), J);
                }
                a("Dispatch scheduled (ms)", Long.valueOf(j2));
                if (this.l.e()) {
                    this.l.b(Math.max(1L, j2 + this.l.d()));
                } else {
                    this.l.a(j2);
                }
            } else {
                I();
                H();
            }
        }
    }

    public final void H() {
        zzbv k2 = k();
        if (k2.z() && !k2.y()) {
            long z = z();
            if (z != 0 && Math.abs(e().a() - z) <= zzby.h.a().longValue()) {
                a("Dispatch alarm scheduled (ms)", Long.valueOf(zzbq.f()));
                k2.A();
            }
        }
    }

    public final void I() {
        if (this.l.e()) {
            a("All hits dispatched or no network/service. Going to power save mode");
        }
        this.l.a();
        zzbv k2 = k();
        if (k2.y()) {
            k2.w();
        }
    }

    public final long J() {
        long j2 = this.k;
        if (j2 != Long.MIN_VALUE) {
            return j2;
        }
        long longValue = zzby.f2533e.a().longValue();
        zzda l2 = l();
        l2.v();
        if (!l2.h) {
            return longValue;
        }
        zzda l3 = l();
        l3.v();
        return ((long) l3.i) * 1000;
    }

    public final void K() {
        v();
        zzk.d();
        this.p = true;
        this.j.x();
        G();
    }

    public final void a(zzas zzas) {
        zzk.d();
        b("Sending first hit to property", zzas.c());
        if (!m().x().a(zzbq.l())) {
            String A = m().A();
            if (!TextUtils.isEmpty(A)) {
                zzr a2 = zzcz.a(f(), A);
                b("Found relevant installation campaign", a2);
                a(zzas, a2);
            }
        }
    }

    public final boolean f(String str) {
        return Wrappers.b(b()).a(str) == 0;
    }

    public final void g(String str) {
        Preconditions.b(str);
        zzk.d();
        zzr a2 = zzcz.a(f(), str);
        if (a2 == null) {
            d("Parsing failed. Ignoring invalid campaign data", str);
            return;
        }
        String A = m().A();
        if (str.equals(A)) {
            d("Ignoring duplicate install campaign");
        } else if (!TextUtils.isEmpty(A)) {
            d("Ignoring multiple install campaigns. original, new", A, str);
        } else {
            m().f(str);
            if (m().x().a(zzbq.l())) {
                d("Campaign received too late, ignoring", a2);
                return;
            }
            b("Received installation campaign", a2);
            for (zzas zzas : this.g.d(0)) {
                a(zzas, a2);
            }
        }
    }

    @Override // com.google.android.gms.internal.gtm.zzan
    public final void u() {
        this.g.t();
        this.h.t();
        this.j.t();
    }

    /* JADX WARNING: Removed duplicated region for block: B:15:0x0044 A[LOOP:1: B:15:0x0044->B:23:?, LOOP_START] */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x0040 A[SYNTHETIC] */
    public final void w() {
        zzk.d();
        zzk.d();
        v();
        if (!zzbq.c()) {
            d("Service client disabled. Can't dispatch local hits to device AnalyticsService");
        }
        if (!this.j.y()) {
            a("Service not connected");
        } else if (!this.g.z()) {
            a("Dispatching local hits to device AnalyticsService");
            while (true) {
                try {
                    List<zzcd> b2 = this.g.b((long) zzbq.g());
                    if (!b2.isEmpty()) {
                        G();
                        return;
                    }
                    while (true) {
                        if (!b2.isEmpty()) {
                            zzcd zzcd = b2.get(0);
                            if (!this.j.a(zzcd)) {
                                G();
                                return;
                            }
                            b2.remove(zzcd);
                            try {
                                this.g.c(zzcd.c());
                            } catch (SQLiteException e2) {
                                e("Failed to remove hit that was send for delivery", e2);
                                I();
                                return;
                            }
                        }
                    }
                    List<zzcd> b22 = this.g.b((long) zzbq.g());
                    if (!b22.isEmpty()) {
                    }
                } catch (SQLiteException e3) {
                    e("Failed to read hits from store", e3);
                    I();
                    return;
                }
            }
        }
    }

    public final void x() {
        v();
        Preconditions.b(!this.f, "Analytics backend already started");
        this.f = true;
        h().a(new p(this));
    }

    public final void y() {
        zzk.d();
        this.o = e().a();
    }

    public final long z() {
        zzk.d();
        v();
        try {
            return this.g.D();
        } catch (SQLiteException e2) {
            e("Failed to get min/max hit times from local store", e2);
            return 0;
        }
    }

    public final void a(long j2) {
        zzk.d();
        v();
        if (j2 < 0) {
            j2 = 0;
        }
        this.k = j2;
        G();
    }

    public final long a(zzas zzas, boolean z) {
        Preconditions.a(zzas);
        v();
        zzk.d();
        try {
            this.g.w();
            k kVar = this.g;
            long b2 = zzas.b();
            String a2 = zzas.a();
            Preconditions.b(a2);
            kVar.v();
            zzk.d();
            int i2 = 1;
            int delete = kVar.y().delete("properties", "app_uid=? AND cid<>?", new String[]{String.valueOf(b2), a2});
            if (delete > 0) {
                kVar.a("Deleted property records", Integer.valueOf(delete));
            }
            long a3 = this.g.a(zzas.b(), zzas.a(), zzas.c());
            zzas.a(1 + a3);
            k kVar2 = this.g;
            Preconditions.a(zzas);
            kVar2.v();
            zzk.d();
            SQLiteDatabase y = kVar2.y();
            Map<String, String> f2 = zzas.f();
            Preconditions.a(f2);
            Uri.Builder builder = new Uri.Builder();
            for (Map.Entry<String, String> entry : f2.entrySet()) {
                builder.appendQueryParameter(entry.getKey(), entry.getValue());
            }
            String encodedQuery = builder.build().getEncodedQuery();
            if (encodedQuery == null) {
                encodedQuery = "";
            }
            ContentValues contentValues = new ContentValues();
            contentValues.put("app_uid", Long.valueOf(zzas.b()));
            contentValues.put("cid", zzas.a());
            contentValues.put("tid", zzas.c());
            if (!zzas.d()) {
                i2 = 0;
            }
            contentValues.put("adid", Integer.valueOf(i2));
            contentValues.put("hits_count", Long.valueOf(zzas.e()));
            contentValues.put("params", encodedQuery);
            try {
                if (y.insertWithOnConflict("properties", null, contentValues, 5) == -1) {
                    kVar2.e("Failed to insert/update a property (got -1)");
                }
            } catch (SQLiteException e2) {
                kVar2.e("Error storing a property", e2);
            }
            this.g.A();
            try {
                this.g.x();
            } catch (SQLiteException e3) {
                e("Failed to end transaction", e3);
            }
            return a3;
        } catch (SQLiteException e4) {
            e("Failed to update Analytics property", e4);
            try {
                this.g.x();
            } catch (SQLiteException e5) {
                e("Failed to end transaction", e5);
            }
            return -1;
        } catch (Throwable th) {
            try {
                this.g.x();
            } catch (SQLiteException e6) {
                e("Failed to end transaction", e6);
            }
            throw th;
        }
    }

    public final void a(zzcd zzcd) {
        Pair<String, Long> b2;
        Preconditions.a(zzcd);
        zzk.d();
        v();
        if (this.p) {
            b("Hit delivery not possible. Missing network permissions. See http://goo.gl/8Rd3yj for instructions");
        } else {
            a("Delivering hit", zzcd);
        }
        if (TextUtils.isEmpty(zzcd.h()) && (b2 = m().B().b()) != null) {
            String str = (String) b2.first;
            String valueOf = String.valueOf((Long) b2.second);
            StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 1 + String.valueOf(str).length());
            sb.append(valueOf);
            sb.append(":");
            sb.append(str);
            String sb2 = sb.toString();
            HashMap hashMap = new HashMap(zzcd.a());
            hashMap.put("_m", sb2);
            zzcd = new zzcd(this, hashMap, zzcd.d(), zzcd.f(), zzcd.c(), zzcd.b(), zzcd.e());
        }
        D();
        if (this.j.a(zzcd)) {
            b("Hit sent to the device AnalyticsService for delivery");
            return;
        }
        try {
            this.g.a(zzcd);
            G();
        } catch (SQLiteException e2) {
            e("Delivery failed to save hit to a database", e2);
            f().a(zzcd, "deliver: failed to insert hit to database");
        }
    }

    public final void a(zzbw zzbw) {
        long j2 = this.o;
        zzk.d();
        v();
        long y = m().y();
        b("Dispatching local hits. Elapsed time since last dispatch (ms)", Long.valueOf(y != 0 ? Math.abs(e().a() - y) : -1));
        D();
        try {
            E();
            m().z();
            G();
            if (zzbw != null) {
                zzbw.a(null);
            }
            if (this.o != j2) {
                this.i.e();
            }
        } catch (Exception e2) {
            e("Local dispatch failed", e2);
            m().z();
            G();
            if (zzbw != null) {
                zzbw.a(e2);
            }
        }
    }

    public final void a(zzas zzas, zzr zzr) {
        Preconditions.a(zzas);
        Preconditions.a(zzr);
        zza zza = new zza(d());
        zza.a(zzas.c());
        zza.a(zzas.d());
        zzg c2 = zza.c();
        zzz zzz = (zzz) c2.b(zzz.class);
        zzz.c("data");
        zzz.b(true);
        c2.a(zzr);
        zzu zzu = (zzu) c2.b(zzu.class);
        zzq zzq = (zzq) c2.b(zzq.class);
        for (Map.Entry<String, String> entry : zzas.f().entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            if ("an".equals(key)) {
                zzq.c(value);
            } else if ("av".equals(key)) {
                zzq.d(value);
            } else if ("aid".equals(key)) {
                zzq.a(value);
            } else if ("aiid".equals(key)) {
                zzq.b(value);
            } else if ("uid".equals(key)) {
                zzz.b(value);
            } else {
                zzu.a(key, value);
            }
        }
        b("Sending installation campaign to", zzas.c(), zzr);
        c2.a(m().w());
        c2.e();
    }
}